import numpy as np
from matplotlib import pyplot as plt

fig=plt.figure()
ax=fig.add_subplot(projection='3d')
# scatter
generate=lambda:np.random.normal(0,1,100)
x=generate()
y=generate()
z=generate()
ax.scatter(x,y,z)
x2,y2,z2=x,y,z
plt.show()
# line graph
x=np.linspace(-6*np.pi,6*np.pi,1000)
y=np.sin(x)
z=np.cos(x)
ax.plot(x,y,z)
plt.show()
# bar chart
x=np.arange(7)
for i in x:
    y=np.arange(10)
    z=abs(np.random.normal(1,10,10))
    ax.bar(y,z,i,zdir='y',color=['r','g','b','y'])
plt.show()
# curved surface
X=np.arange(-2,2,0.1)
Y=np.arange(-2,2,0.1)
X,Y=np.meshgrid(X,Y)
Z=np.sqrt(X**2+Y**2)
ax.plot_surface(X,Y,Z,cmap=plt.cm.winter)
plt.show()
# mixed graph
x1=np.linspace(-3*np.pi,3*np.pi,500)
y1=np.sin(x1)
ax.plot(x1,y1,zs=0,c='red')
ax.scatter(x2,y2,z2)
plt.show()
# group
fig=plt.figure(figsize=(8,4))
ax1=fig.add_subplot(1,2,1,projection='3d')
x=np.linspace(-6*np.pi,6*np.pi,1000)
y=np.sin(x)
z=np.cos(x)
ax1.plot(x,y,z)
ax2=fig.add_subplot(122,projection='3d')
X=np.arange(-2,2,0.1)
Y=np.arange(-2,2,0.1)
X,Y=np.meshgrid(X,Y)
Z=np.sqrt(X**2+Y**2)
ax2.plot_surface(X,Y,Z,cmap=plt.cm.summer)
plt.show()
